package com.cdks.wuxiu.api.service.mysql;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.cdks.wuxiu.api.component.constant.Constant;
import com.cdks.wuxiu.api.mapper.WithdrawRatioConfigMapper;
import com.cdks.wuxiu.entity.mysql.WithdrawRatioConfig;

import java.util.List;

import org.springframework.stereotype.Service;


/**
 * 提现参数配置表 服务实现类
 */
@Service
public class WithdrawRatioConfigServiceImpl extends ServiceImpl<WithdrawRatioConfigMapper, WithdrawRatioConfig> implements WithdrawRatioConfigService {
    @Override
    public WithdrawRatioConfig getByAuthWithType(int authLevel, int type) {
        QueryWrapper<WithdrawRatioConfig> wrapper  = new QueryWrapper<>();
        wrapper.lambda().eq(WithdrawRatioConfig::getAuthLevel, authLevel)
                        .eq(WithdrawRatioConfig::getType, type)
                        .eq(WithdrawRatioConfig::getStatus, Constant.ENABLE_YES);
        
        return baseMapper.selectOne(wrapper);
    }

    @Override
    public List<WithdrawRatioConfig> getValidConfig() {
        QueryWrapper<WithdrawRatioConfig> wrapper = new QueryWrapper<>();
        wrapper.lambda().eq(WithdrawRatioConfig::getStatus, Constant.ENABLE_YES)
                        .groupBy(WithdrawRatioConfig::getType)
                        .select(WithdrawRatioConfig::getType);
        
        return baseMapper.selectList(wrapper);
    }
}
